import { v4 as uuidv4 } from "uuid";

class Message {
  constructor(type, sender, receiver, message) {
    this._id = uuidv4();
    this.type = type;
    this.sender = sender;
    this.receiver = receiver;
    this.message = message;
    this.timestamp = Date.now();
  }

  // 普通消息工厂方法
  static createMessage(sender, receiver, message) {
    return new Message("MESSAGE", sender, receiver, message);
  }

  // 系统消息工厂方法
  static createSystemMessage(receiver, message) {
    return new Message("SYSTEM_MESSAGE", null, receiver, message);
  }
}

export default Message;
